package cn.edu.jju.psytest.persist;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import cn.edu.jju.psytest.model.entity.QuizRecord;

@SuppressWarnings("restriction")
@Repository
public class QuizRecordDao {

	private HibernateTemplate hibernateTemplate;

	public void saveQuizRecord(QuizRecord quizRecord) {
		hibernateTemplate.save(quizRecord);
	}

	public List<?> getQuizTestTime() {
		return hibernateTemplate
				.find("select distinct(createdDate) from QuizRecord");
	}

	public List<?> getQuizAnswers(String userId) {
		return hibernateTemplate.find(
				"select answers from QuizRecord where studentId = ?", userId);
	}

	/**
	 * Getters And Setters
	 */
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
}
